<?php


namespace app\admin\controller\virtual;


use app\admin\model\PushStoreRule as PushStoreRuleModel;
use think\Request;
use app\admin\model\Qu as QuModel;

class Qu
{
    public function list(Request $request)
    {
        $title = $request->param("title");
        $quId = $request->param("qu_id");
        $staffNo = $request->param("staff_no");
        $res = QuModel::list($title,$quId,$staffNo);
        return successJson("success",$res);
    }

    public function add(Request $request)
    {
        $title = $request->param("title");
        $text = $request->param("text");
        $quId = $request->param("qu_id");
        $u = $request->_user;
        $p = QuModel::add($title,$text,$quId,$u["staff_no"],$u["staff_name"]);
        if($p) return failedJson($p);
        return successJson("success");
    }

    public function up(Request $request)
    {
        $id = $request->param("id");
        $title = $request->param("title");
        $text = $request->param("text");
        $quId = $request->param("qu_id");
        $u = $request->_user;
        $p = QuModel::up($title,$text,$quId, $id);
        if($p) return failedJson($p);
        return successJson("success");
    }

    public function del(Request $request)
    {
        $id = $request->param("id");
        $p = QuModel::del($id);
        if($p) return failedJson($p);
        return successJson("success");
    }
}